home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / unpetite.txt < prev    next >
Encoding:
Text File  |  1999-08-18  |  9.0 KB  |  183 lines

  1.  
  2.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  3.     ▓▓    ____                     __       __           ▓▓▀█
  4.     ▓▓   /  _/_ _  __ _  ___  ____/ /____ _/ /           ▓▓ █▀█
  5.     ▓▓  _/ //  ' \/  ' \/ _ \/ __/ __/ _ `/ /            ▓▓ █ █
  6.     ▓▓ /___/_/_/_/_/_/_/\___/_/  \__/\_,_/_/             ▓▓ █ █
  7.     ▓▓   ____                          __          __    ▓▓ █ █     
  8.     ▓▓  / __ \___ ___ _______ ___  ___/ /__ ____  / /____▓▓ █ █ 
  9.     ▓▓ / /_/ / -_|_-</ __/ -_) _ \/ _  / _ `/ _ \/ __(_-<▓▓ █ █
  10.     ▓▓/_____/\__/___/\__/\__/_//_/\_,_/\_,_/_//_/\__/___/▓▓ █ █
  11.     ▓▓                                                   ▓▓ █ █
  12.     ▓▓      Web: http://www.ImmortalDescendants.com      ▓▓ █ █
  13.     ▓▓                Author: Volatility                 ▓▓ █ █
  14.     ▓▓                  Date: 08/17/99                   ▓▓ █ █
  15.     ▓▓        Topic: Quequero's Patience CrackMe         ▓▓ █ █
  16.     ▓▓               (Manually Unpacking)                ▓▓ █ █
  17.     ▓▓            Level: Beginner/Intermediate           ▓▓ █ █
  18.     ▓▓                                                   ▓▓ █ █
  19.     ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ █ █
  20.       █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ █
  21.         █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
  22.  
  23. =========================================================================
  24. INTRODUCTION:
  25. =========================================================================
  26.  
  27. This is a very simple crackme, as Quequero states in his readme file, but
  28. I chose to manually unpack it, because I had never tried unpacking a file
  29. packed with the Petite packer.  I'm not going to go into great detail 
  30. about unpacking, and PE information... for more information, I suggest
  31. you read my essay "Manually Unpacking - ASPack v1.08.03" available at my
  32. website (http://www.ImmortalDescendants.com).
  33.  
  34. =========================================================================
  35. TOOLS NEEDED:
  36. =========================================================================
  37.  
  38. 1. NuMega Soft-Ice (any version for windows)
  39. 2. uCF's ProcDump
  40. 3. GetTyp
  41.  
  42. =========================================================================
  43. THE ESSAY:
  44. =========================================================================
  45.  
  46. By reading the readme file included with the crackme, we know the program
  47. is packed (not by which packer yet).  We also know that we can't patch or
  48. disassemble the program.  We know we need to look for valid serial 
  49. numbers, and some kind of "surprise" :)
  50.  
  51. With that information, our first step should be determining which packer
  52. the program is packed with, and then to manually unpack it.
  53.  
  54. GetTyp is a nice little program that determines which packer a program is
  55. packed with.  You can find it readily available on the web.  After 
  56. opening the crackme with GetTyp, we get the following information:
  57. "Packer: Petite 1.2".  Now we know which packer is used.
  58.  
  59. I had never tried to manually unpack a program packed with this packer,
  60. but was sure I could achieve it using the same methods I use to unpack
  61. ASPack packed programs.  I tested unpacking this program using ProcDump,
  62. and it works just fine... but I choose to manually unpack, as it's more
  63. interesting.
  64.  
  65. To manually unpack this program, we need to load it with Soft-Ice's 
  66. Symbol Loader.  Choose "File", "Open Module" then "Module", "Load".
  67. Click "Yes" on the message box, then Soft-Ice will break.  The following
  68. is my Soft-Ice log.  I've commented all the lines you'll need to note:
  69.  
  70. =========================================================================
  71. BEGIN LOG FILE
  72. =========================================================================
  73.  
  74. 015F:00405000  FFFF                INVALID  ** Break here
  75. 015F:00405002  60                  PUSHAD
  76. 015F:00405003  E8CA000000          CALL    004050D2
  77.  
  78. ** Trace into above call (F8) to get into the unpacking routine
  79.  
  80. 015F:004050D2  58                  POP     EAX  ** Land here inside call
  81. 015F:004050D3  2C08                SUB     AL,08
  82. 015F:004050D5  50                  PUSH    EAX
  83. 015F:004050D6  8BC8                MOV     ECX,EAX
  84. 015F:004050D8  8BD0                MOV     EDX,EAX
  85. 015F:004050DA  81C1C0D20000        ADD     ECX,0000D2C0
  86. 015F:004050E0  81C22F160000        ADD     EDX,0000162F
  87. 015F:004050E6  8920                MOV     [EAX],ESP
  88. 015F:004050E8  8BE1                MOV     ESP,ECX
  89. 015F:004050EA  50                  PUSH    EAX
  90. 015F:004050EB  812C2400500000      SUB     DWORD PTR [ESP],00005000
  91. 015F:004050F2  FF30                PUSH    DWORD PTR [EAX]
  92. 015F:004050F4  50                  PUSH    EAX
  93. 015F:004050F5  80042408            ADD     BYTE PTR [ESP],08
  94. 015F:004050F9  50                  PUSH    EAX
  95. 015F:004050FA  80042446            ADD     BYTE PTR [ESP],46
  96. 015F:004050FE  50                  PUSH    EAX
  97. 015F:004050FF  80042465            ADD     BYTE PTR [ESP],65
  98. 015F:00405103  50                  PUSH    EAX
  99. 015F:00405104  800424A1            ADD     BYTE PTR [ESP],A1
  100. 015F:00405108  50                  PUSH    EAX
  101. 015F:00405109  800424BF            ADD     BYTE PTR [ESP],BF
  102. 015F:0040510D  833A00              CMP     DWORD PTR [EDX],00
  103. 015F:00405110  0F84A7140000        JZ      004065BD             (NO JUMP)
  104. 015F:00405116  F70200000080        TEST    DWORD PTR [EDX],80000000
  105. 015F:0040511C  741B                JZ      00405139             (JUMP )
  106. 015F:00405139  52                  PUSH    EDX
  107. 015F:0040513A  FF32                PUSH    DWORD PTR [EDX]
  108. 015F:0040513C  8B5A08              MOV     EBX,[EDX+08]
  109. 015F:0040513F  035C2420            ADD     EBX,[ESP+20]
  110.  
  111. ** Get OEP from above line after looping once (explained later)
  112.  
  113. 015F:00405143  53                  PUSH    EBX
  114. 015F:00405144  8B5A04              MOV     EBX,[EDX+04]
  115. 015F:00405147  035C2424            ADD     EBX,[ESP+24]
  116. 015F:0040514B  53                  PUSH    EBX
  117. 015F:0040514C  E84A000000          CALL    0040519B
  118. 015F:00405151  85C0                TEST    EAX,EAX
  119. 015F:00405153  741F                JZ      00405174             (NO JUMP)
  120. 015F:00405155  8B7C2404            MOV     EDI,[ESP+04]
  121. 015F:00405159  83C40C              ADD     ESP,0C
  122. 015F:0040515C  5A                  POP     EDX
  123. 015F:0040515D  8B4A0C              MOV     ECX,[EDX+0C]
  124. 015F:00405160  C1F902              SAR     ECX,02
  125. 015F:00405163  33C0                XOR     EAX,EAX
  126. 015F:00405165  F3AB                REPZ STOSD
  127. 015F:00405167  8B4A0C              MOV     ECX,[EDX+0C]
  128. 015F:0040516A  83E103              AND     ECX,03
  129. 015F:0040516D  F3AA                REPZ STOSB
  130. 015F:0040516F  83C210              ADD     EDX,10
  131. 015F:00405172  EB99                JMP     0040510D             (JUMP )
  132.  
  133. ** Stop here!
  134.  
  135. =========================================================================
  136. END LOG FILE
  137. =========================================================================
  138.  
  139. As you can see from the code above, we need to trace into the call at
  140. 00405003 to get into the unpacking routine.  Once inside the call, simply
  141. trace through it, until you get to the final jump at 00405172.  Execute 
  142. this jump, and you'll be back at the beginning of the routine again.  
  143. Trace again until you get to 0040513F.  Note the value of EBX here 
  144. (should be 00401000).  This is the OEP (read the essay I mentioned for
  145. more info on this).
  146.  
  147. Now that we have the OEP, trace to the jump again, execute it again, and
  148. trace one final time to it.  Now everything is unpacked in memory, so at
  149. 00405172 type:
  150.  
  151. a eip (hit enter)
  152. jmp eip (hit enter)
  153. (hit enter again)
  154.  
  155. Now we can Cntrl+D to get out of Soft-Ice.  Our program is unpacked in
  156. memory, so run ProcDump, find the program in the list of tasks, right
  157. click on it and choose "Dump (Full)".  Choose a new filename, and save
  158. the dump.  Now right click on it again, and choose "Kill Task".  We now 
  159. have an unpacked copy of the program.  Check the file size of the 
  160. original, and unpacked copy to verify this.
  161.  
  162. If you try to run the unpacked copy now, you'll get an error and the 
  163. program will crash.  We need to change the entry point.  So, run ProcDump 
  164. again, and choose "PE Editor".  Open the unpacked program, and change 
  165. "Entry Point" to the value you wrote down from EBX.  This is calculated 
  166. from OEP - Image Base... so, 00401000 - 00400000 = 00001000.  Change 
  167. the Entry Point to 00001000, and the program runs!
  168.  
  169. The rest of the crack is simple, so I won't list that part of it here.
  170. Simply break on GetWindowTextA and display the registers or open the 
  171. program up in a hex editor, and look at the text :)
  172.  
  173. =========================================================================
  174. GREETINGS (in no order of importance):
  175. =========================================================================
  176.  
  177. Eternal Bliss, Torn@do, Lucifer48, Jeff, +Sandman, Lord Soth, alpine,
  178. GoFnoR, Carpathia, ytc_, _y, night-, `fresh, CrackZ, and everyone I 
  179. forgot in #Cracking4Newbies.
  180.  
  181. =========================================================================
  182. Copyright (c) 1999 Volatility And The Immortal Descendants
  183. All Rights Reserved